<template>
	<view class="page">
		<view class="main">
			<view class="list" v-for="(item,index) in lists">
				<view class="top">
					<view class="tx-wrap">
						<u-avatar size="88rpx" :src="item.headImg?fileServer+item.headImg:null"></u-avatar>
						<view class="xz flexAJC">
							<view class="dian"></view>
							在线
						</view>
					</view>
					<view class="user">
						<view class="name-wrap flexACB">
							<view class="name-left flexAC">
								<view class="name">
									{{item.memberName}}
								</view>
								<view class="label">
									{{item.position}}
								</view>
								<image class="vip" src="../../../static/img/vip-icon.png" mode="widthFix"></image>
								<view class="dept">
									{{typeList[item.type].label}}
								</view>
							</view>
							<view class="talk-btn flexAJC" @click="delThis(item.id)">
								</image>
								删除
							</view>
						</view>
						<view class="ads">
							<image class="icon" src="../../../static/img/gongsi.png" mode="widthFix"></image>
							{{item.companyName}}
						</view>
					</view>
				</view>
				<view class="content">
					主营品牌产品：{{item.zypphcp}}
				</view>
				<view class="content-text">
					{{item.content}}
				</view>
				<view class="img-list">
					<image class="img" v-for="i in item.productImg" :src="i"></image>
				</view>
			</view>
		</view>
		<view class="fb-btn flexAJC" @click="toAdd">
			<image class="icon" src="../../../static/img/fabubiaoshu.png" mode="widthFix"></image>
			发布
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pageIndex: 1,
				total: 0,
				lists: [],
				fileServer: this.$fileServer,
				typeList: [],
			};
		},
		onShow() {
			this.typeList = getApp().globalData.typeList
			this.lists = []
			this.pageIndex = 1
			this.getList()
		},
		onReachBottom() {
			++this.pageIndex
			this.getList()
		},
		methods: {
			delThis(id) {
				uni.showModal({
					content: "确认删除该发布？",
					success: (res) => {
						if (res.confirm) {
							this.$api.duijie.delGxfbById({
								id: id
							}).then(res => {
								this.lists = []
								this.pageIndex = 0
								this.getList()
							})
						}
					}
				})
			},
			getList(idx) {
				this.$api.duijie.getGxfbList({
					pageIndex: this.pageIndex
				}).then(res => {
					this.total = res.total
					if (res.rows.length > 0) {
						res.rows = res.rows.map(item => {
							if (item.productImg.length > 0) {
								item.productImg = item.productImg.split(',').map(i => {
									return this.fileServer + i
								})
							}
							return {
								...item
							}
						})
						this.lists = this.lists.concat(res.rows)
					} else {
						--this.pageIndex
					}
				})
			},
			toAdd() {
				uni.navigateTo({
					url: "/pages/mine/issueAdd/issueAdd"
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		background-color: #F5F5F5;
		min-height: 100vh;

		.top-view {
			width: 100%;
			background-color: #fff;
			padding: 20rpx 32rpx 0;

			.find {
				display: flex;
				justify-content: space-between;
				margin-top: 20rpx;

				.find-item {
					position: relative;
					width: 336rpx;
					height: 170rpx;

					.find-bg {
						position: absolute;
						width: 100%;
						height: 100%;
						left: 0;
						top: 0;
						z-index: 1;
					}

					.find-content {
						position: relative;
						z-index: 2;
						width: 100%;
						height: 100%;
						padding: 16rpx 16rpx 0;

						.f-name {

							font-size: 32rpx;
							font-weight: bold;
							line-height: 44rpx;
						}

						.f-desc {

							line-height: 34rpx;
							color: #777777;
						}

						.f-btn {
							margin-top: 10rpx;
							width: 124rpx;
							height: 50rpx;

							border-radius: 25rpx;
							color: #FFFFFF;

							&.red {
								background: #E96056;
							}

							&.blue {
								background: #69A9FF;
							}
						}
					}
				}
			}

			.search-wrap {
				width: 100%;
				padding: 28rpx 0 24rpx;

				.search-item {
					height: 44rpx;
					display: flex;
					align-items: center;

					.text {
						font-size: 32rpx;
						line-height: 44rpx;
					}

					.down {
						width: 29rpx;
						height: auto;
					}
				}
			}
		}

		.main {
			width: 100%;
			padding: 24rpx 32rpx;

			.list {
				width: 100%;
				background: #FFFFFF;
				border-radius: 16rpx;
				margin-bottom: 38rpx;
				padding: 18rpx 24rpx 20rpx 16rpx;

				.top {
					display: flex;

					.tx-wrap {
						position: relative;
						width: 88rpx;
						height: 88rpx;

						.tx {
							width: 88rpx;
							height: 88rpx;
							border-radius: 50%;
						}

						.xz {
							position: absolute;
							z-index: 2;
							width: 60rpx;
							height: 28rpx;
							background: #C1E4C6;
							border-radius: 14rpx;
							font-size: 18rpx;
							color: #48B547;
							bottom: -14rpx;
							left: 50%;
							transform: translateX(-50%);

							.dian {
								width: 4rpx;
								height: 4rpx;
								background: #48B547;
								border-radius: 50%;
								margin-right: 4rpx;
							}
						}
					}

					.user {
						width: calc(100% - 88rpx);
						padding-left: 16rpx;

						.name-wrap {
							.name-left {
								line-height: 44rpx;

								.name {

									font-size: 32rpx;
									font-weight: bold;
									margin-right: 10rpx;
								}

								.label {
									font-size: 24rpx;
									color: #AAAAAA;
									margin-right: 6rpx;
								}

								.vip {
									width: 28rpx;
									height: auto;
									margin-left: 6rpx;
								}

								.dept {
									height: 36rpx;
									border-radius: 18rpx;
									background: #FFE9E9;
									color: #E83149;
									font-size: 20rpx;
									padding: 0 20rpx;
									line-height: 36rpx;
									margin-left: 6rpx;
								}
							}

							.talk-btn {
								width: 120rpx;
								height: 50rpx;
								background: #EC2424;
								border-radius: 25rpx;
								color: #FFFFFF;

								.icon {
									width: 20rpx;
									height: auto;
								}
							}
						}

						.ads {
							color: #777777;
							font-size: 28rpx;
							line-height: 40rpx;

							.icon {
								display: inline-block;
								width: 24rpx;
								height: auto;
								margin-right: 6rpx;
							}
						}
					}
				}
			}

			.content {
				color: #AAAAAA;
				line-height: 40rpx;
				font-size: 28rpx;
				margin-bottom: 10rpx;
				margin-top: 22rpx;
			}

			.content-text {
				padding: 20rpx 0 0 0;
				font-size: 28rpx;
				border-top: 1px solid #F0F0F0;
			}

			.img-list {
				overflow: hidden;
				width: 100%;

				.img {
					width: 200rpx;
					height: 200rpx;
					margin-right: 22rpx;
					margin-top: 20rpx;
					border-radius: 16rpx;

					&:nth-child(3n+0) {
						margin-right: 0;
					}
				}
			}

		}

		.fb-btn {
			position: fixed;
			right: 14rpx;
			bottom: 24rpx;
			width: 164rpx;
			height: 70rpx;
			background: #EC2424;
			box-shadow: 1px 6 8rpx 0px rgba(236, 36, 36, 0.33);
			border-radius: 35rpx;
			z-index: 99;

			color: #FFFFFF;
			font-size: 26rpx;

			.icon {
				width: 30rpx;
				height: auto;
				margin-right: 4rpx;
			}
		}
	}
</style>